package com.jxltech.unicam.utils;

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.border.LineBorder;

public class TestJSplitPane {

	private JFrame jframeMain = new JFrame();
	private JPanel jpanelMain = new JPanel();

	// 用于分割两个（只能两个）component
	private JSplitPane jsplitPaneTestOne = new JSplitPane();
	// 上下
	private JSplitPane jsplitPaneTextTwo = new JSplitPane(
			JSplitPane.VERTICAL_SPLIT);

	public TestJSplitPane() {
// TODO Auto-generated constructor stub
// 设置分隔条的位置
		jsplitPaneTestOne.setDividerLocation(40);
// 将组件分配到分隔符的左边
		jsplitPaneTestOne.setLeftComponent(new JLabel("左边"));

		jsplitPaneTextTwo.setDividerLocation(80);
//设置分隔条的大小
		jsplitPaneTextTwo.setDividerSize(20);
//快速展开/折叠分隔条（默认为false）
		jsplitPaneTextTwo.setOneTouchExpandable(true);
		jsplitPaneTextTwo.setLeftComponent(new JLabel("上面"));
		jsplitPaneTextTwo.setRightComponent(new JLabel("下面"));


// 将组件分配到分隔符的右边
		jsplitPaneTestOne.setRightComponent(jsplitPaneTextTwo);

		jpanelMain.setBorder(new LineBorder(Color.red));

//设置jpanelMain的布局管理
		jpanelMain.setLayout(new BorderLayout());

		jpanelMain.add(jsplitPaneTestOne);
		jframeMain.add(jpanelMain);

		jframeMain.setTitle("分割面板");
		jframeMain.setSize(500, 600);
		jframeMain.setLocationRelativeTo(null);
		jframeMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jframeMain.setVisible(true);
	}

	public static void main(String[] args) {
		new TestJSplitPane();
	}
}
